/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package actioncombination.logic.agent.action;

import actioncombination.common.datastructure.DataStructure;
import actioncombination.common.value.Value;
import actioncombination.logic.agent.action.Action;
import java.util.ArrayList;
/**
 *
 * @author Administrador
 */
public abstract class ActionVelocity extends Action{
    
    private ArrayList typesOfVelocity;

    public ActionVelocity() {
    }

    
    public ActionVelocity(ArrayList typesOfVelocity) {
        this.typesOfVelocity = typesOfVelocity;
    }
    
   protected int getActionIndex(Value velocity) throws Exception{
        for (int i=0;i<getTypesOfVelocity().size();i++){
            if(velocity==getTypesOfVelocity().get(i))
                return i;
        }
        throw new Exception("no existe ese angulo en la lista");
    }
    
    public boolean validateVelocity(DataStructure velocity, ActionVelocity nextVelocity) {
        DataStructure maxVelocity =  (DataStructure) getTypesOfVelocity().get(getTypesOfVelocity().size() - 1);
        DataStructure minVelocity =  (DataStructure) getTypesOfVelocity().get(0);
        if ((velocity == minVelocity && nextVelocity instanceof DecrementVelocity ) || (velocity == maxVelocity && nextVelocity instanceof IncrementVelocity)) {
            return false;
        } else {
            return true;
        }

    }

    public void setTypesOfVelocity(ArrayList typesOfVelocity) {
        this.typesOfVelocity = typesOfVelocity;
    }

    public ArrayList getTypesOfVelocity() {
        return typesOfVelocity;
    }
}
